#!/bin/sh
systemctl start ntpd
#setenforce 0
umask 0022

echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag

if [[ "$AMBARI_AGENT" =~ "," ]];then
  i=1
  while ((1 == 1))
  do
    AMBARI_AGENT_HOST=`echo $AMBARI_AGENT|cut -d "," -f $i`
    if [ -z "$AMBARI_AGENT_HOST" ];then
      break;
    fi
    sshpass -p 'Ambari123456@@' ssh-copy-id -p 222 -o "StrictHostKeyChecking no" $AMBARI_AGENT_HOST
    ((i++))
  done
else
  sshpass -p 'Ambari123456@@' ssh-copy-id -p 222 -o "StrictHostKeyChecking no" $AMBARI_AGENT
fi

ambari-server setup -s -j /usr/local/jdk1.8.0_333 --database=$DATABASE --databasehost=$DATABASE_HOST --databaseport=$DATABASE_PORT --databasename=$DATABASE_NAME --databaseusername=$DATABASE_USERNAME --databasepassword=$DATABASE_PASSWORD